package com.wf.day_0607.test3;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Objects;

/**
 * @author mpk
 * @since 2024/6/7 17:59:26
 */
public class UTFGBKTest {
    public static void main(String[] args) throws IOException {


        try (BufferedReader reader = new BufferedReader(new InputStreamReader(
                Objects.requireNonNull(UTFGBKTest.class.getResourceAsStream("test.txt")), StandardCharsets.UTF_8));


             BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
                     Files.newOutputStream(Paths.get("src/com/wf/day_0607/test3/test3.txt")), "GBK"))

        ) {


            String line;

            while ((line = reader.readLine()) != null) {

                System.out.println(line);
                if (!"//".equals(line.substring(0, 2))) {
                    writer.write(line);
                    writer.newLine();
                    writer.flush();
                }

            }


        }


    }


}
